<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 18-8-9
 * Time: 上午11:10
 */

namespace api\modules\chedai\controllers;


use common\models\AliFaceValidate;
use wodrow\yii\rest\Controller;

class FaceValidateController extends Controller
{
    /**
     * 获取人脸识别结果 【银联阿里同时查询】
     * @desc get/post
     * @param string $idcard
     * @return array
     */
    public function actionGetFaceValidate($idcard)
    {
        $unipay = \Yii::$app->runAction('chedai/unionpay/get3002-by-id-card', ['id_card' => $idcard, 'is_last' => 1]);
        $unipay = $unipay['data'];
        if ($unipay['status_message'] == "业务处理成功" || ($unipay['status'] == 10 && $unipay['score'] >= 70)){
            return [
                'audit' => AliFaceValidate::AUDIT_PASS,
            ];
        }
        $ali = \Yii::$app->runAction('chedai/ali/get-ali-face-validate-by-idcard', ['idcard' => $idcard]);
        $ali = $ali['data'];
        return [
            'audit' => $ali['ali_fv']['audit'],
        ];
    }
}